/**
 * Created by Wang on 2018/7/16.
 */
(function () {
    var myContext = Java.type("cn.edu.hit.kg.ScriptContext").getInstance();
    var toRawArray = myContext.getService("toRawArray");
    var neighbor = function (array) {
        return toRawArray(array).slice(1).map(function (e, i) {
            return {
                x: array[i],
                y: e
            }
        });
    };
    myContext.registService('neighbor', '1.0.0', neighbor);

    var groups = function (array, size) {
        while (array.length < size) {
            array.push(array[array.length - 1])
        }
        return array.slice(size - 1).map(function (e, i) {
            return array.slice(i, i + size)
        });
    };
    myContext.registService('groups', '1.0.0', groups);

})();
